﻿(function () {
    require.config({
        paths: {
			echarts: "echarts",
		},
    });
    var track = [[${track}]];
    console.log(track[0]);
    require(
    [
        "echarts",
        "echarts/chart/main",
		"echarts/chart/map",	
    ],
    function (echarts, BMapExtension) {
        $('#main').css({
            height:$('body').height(),
            width:$('body').width()
        });

        // 初始化地图
        var BMapExt = new BMapExtension($('#main')[0], BMap, echarts,{
            enableMapClick: false
        });
        var map = BMapExt.getMap();
        var container = BMapExt.getEchartsContainer();

        var startPoint = {
            //x: 113.328755, //天河城
            //y: 23.135588
            x:116.363702,
            y:40.00938  //中国农业大学一号公寓
        };

        var point = new BMap.Point(startPoint.x, startPoint.y);
        map.centerAndZoom(point, 17);
        map.enableScrollWheelZoom(true);
        // 地图自定义样式
        map.setMapStyle({
           styleJson: [
          {
                    'featureType': 'land',     //调整土地颜色
                    'elementType': 'geometry',
                    'stylers': {
                              'color': '#081734'
                    }
          },
          {
                    'featureType': 'building',   //调整建筑物颜色
                    'elementType': 'geometry',
                    'stylers': {
                              'color': '#04406F'
                    }
          },
         {
                    'featureType': 'building',   //调整建筑物标签是否可视
                    'elementType': 'labels',
                    'stylers': {
                    'visibility': 'off'
                    }
          },
          {
                    'featureType': 'highway',     //调整高速道路颜色
                    'elementType': 'geometry',
                    'stylers': {
                    'color': '#015B99'
                    }
          },
          {
                    'featureType': 'highway',    //调整高速名字是否可视
                    'elementType': 'labels',
                    'stylers': {
                    'visibility': 'off'
                    }
          },
          {
                    'featureType': 'arterial',   //调整一些干道颜色
                    'elementType': 'geometry',
                    'stylers': {
                    'color':'#003051'
                    }
          },
          {
                    'featureType': 'arterial',
                    'elementType': 'labels',
                    'stylers': {
                    'visibility': 'off'
                    }
          },
          {
                    'featureType': 'green',
                    'elementType': 'geometry',
                    'stylers': {
                    'visibility': 'off'
                    }
          },
          {
                    'featureType': 'water',
                    'elementType': 'geometry',
                    'stylers': {
                              'color': '#044161'
                    }
          },
          {
                    'featureType': 'subway',    //调整地铁颜色
                    'elementType': 'geometry.stroke',
                    'stylers': {
                    'color': '#003051'
                    }
          },
          {
                    'featureType': 'subway',
                    'elementType': 'labels',
                    'stylers': {
                    'visibility': 'off'
                    }
          },
          {
                    'featureType': 'railway',
                    'elementType': 'geometry',
                    'stylers': {
                    'visibility': 'off'
                    }
          },
          {
                    'featureType': 'railway',
                    'elementType': 'labels',
                    'stylers': {
                    'visibility': 'off'
                    }
          },
          {
                    'featureType': 'all',     //调整所有的标签的边缘颜色
                    'elementType': 'labels.text.stroke',
                    'stylers': {
                              'color': '#313131'
                    }
          },
          {
                    'featureType': 'all',     //调整所有标签的填充颜色
                    'elementType': 'labels.text.fill',
                    'stylers': {
                              'color': '#FFFFFF'
                    }
          },
          {
                    'featureType': 'manmade',   
                    'elementType': 'geometry',
                    'stylers': {
                    'visibility': 'off'
                    }
          },
          {
                    'featureType': 'manmade',
                    'elementType': 'labels',
                    'stylers': {
                    'visibility': 'off'
                    }
          },
          {
                    'featureType': 'local',
                    'elementType': 'geometry',
                    'stylers': {
                    'visibility': 'off'
                    }
          },
          {
                    'featureType': 'local',
                    'elementType': 'labels',
                    'stylers': {
                    'visibility': 'off'
                    }
          },
          {
                    'featureType': 'subway',
                    'elementType': 'geometry',
                    'stylers': {
                              'lightness': -65
                    }
          },
          {
                    'featureType': 'railway',
                    'elementType': 'all',
                    'stylers': {
                              'lightness': -40
                    }
          },
          {
                    'featureType': 'boundary',
                    'elementType': 'geometry',
                    'stylers': {
                              'color': '#8b8787',
                              'weight': '1',
                              'lightness': -29
                    }
          }
    ]
        });

option = {
    color: ['gold','aqua','lime'],
    title : {
        text: '',
        subtext: '',
        x:'center',
        textStyle : {
            color: '#fff',
			fontSize:20,
			fontWeight:'bold',
        }
    },
    tooltip : {
        show: true,
		trigger:'item',
		hideDelay:4000,
        formatter: function(d) {
			var jw ='经度：'+d.value[0]+'<br/>'
			    jw += '纬度：'+d.value[1]
			return jw       
        }
	},
	color:['gold','red'],
	legend:{
		data:['上学轨迹(甲)','逛街购物轨迹(乙,丙)'],
		x:'left',
		orient:'vertical',
		padding:[30,15,15,30],
		textStyle:{
			fontSize:17,
			color:'rgb(204,204,204)',
		},
		selected:{
			'上学轨迹(甲)':true,
			'逛街购物轨迹(乙,丙)':false,
		},
		selectedMode:'single',
	},
	/*
    toolbox: {
        show : true,
        orient : 'vertical',
        x: 'right',
        y: 'center',
        feature : {
           mark : {show: true},
           dataView : {show: true, readOnly: false},
           restore : {show: true},
           saveAsImage : {show: true}
        }
    },*/
  series : [
  {
	  name:'上学轨迹(甲)',
      type:'map',
      mapType: 'none',
      data:[],
      
      markLine : {
      Symbol:['none', 'arrow'],
      symbolSize:['0', '0.1'],
      smooth:true,
      smooth:0,
      effect : {
          show: true,
          scaleSize: 1,
          period: 30,
          color: '#fff',
          shadowBlur: 10
      },
      itemStyle : {
          color: 'red',
          normal: {
              color:function(param){
              return(param.data[0].value.colorValue);
              },
              borderWidth:3,
              lineStyle: {
                  type: 'solid',
                  width: 3,
                  shadowBlur: 10
              },
              label:{show:false,value:'中国农业大学一号公寓'}
        }
      },

    data : [
	            [{name:'p1'}, {name:'p2',value:{colorValue:'gold'}}],
                [{name:'p2'}, {name:'p3',value:{colorValue:'gold'}}],
                [{name:'p3'}, {name:'p4',value:{colorValue:'gold'}}],
				[{name:'p4'}, {name:'p1',value:{colorValue:'gold'}}]
		]
		},
	  markPoint:{
			symbol:'image://./img/location.svg',
			symbolSize:function(v){
				return v/5
			},
			effect:{
			    show:true,
                type:'bounce',
                period:3,				
			},
			itemStyle:{
				normal:{
					label:{
						show:false,
					},
				},
				emphasis:{
					label:{
						show:false,
					},
				},
			},
			data:[
			   {name:'p1',value:50,
			       tooltip:{
					   formatter:'时间:8:30am<br/>出发地:中国农业大学一号公寓'
				   },
			   },
			   {name:'p2',value:100,
			       tooltip:{
					   formatter:'三教<br/>经度:116.363603<br/>纬度:40.010596'
				   },
			   },
			   {name:'p4',value:50,
			       tooltip:{
					   formatter:'时间:12:00am<br/>目的地:风味餐厅'
				   },
			   },
			],
		},
      geoCoord:{
                 'p1':[116.363702,40.00938], //中国农业大学一号公寓], //寝室
                 'p2':[116.363603,40.010596], //三教
                 'p3':[116.365588,40.011895], //图书馆
                 'p4':[116.368292,40.009083], //风味餐厅
      }
},
	
	
	
{
	  name:'逛街购物轨迹(乙,丙)',
      type:'map',
      mapType: 'none',
      data:[],
      
      markLine : {
      Symbol:['none', 'arrow'],
      symbolSize:['0', '0.1'],
      smooth:true,
      smooth:20,
      effect : {
          show: true,
          scaleSize: 1,
          period: 30,
          color: '#fff',
          shadowBlur: 10
      },
      itemStyle : {
          color: 'red',
          normal: {
              color:function(param){
              return(param.data[0].value.colorValue);
              },
              borderWidth:3,
              lineStyle: {
                  type: 'solid',
                  width: 3,
                  shadowBlur: 10
              },
              label:{show:false,value:'天河城'}
        }
      },

    data : [
	            [{name:'s1'}, {name:'s2',value:{colorValue:'gold'}}],
                [{name:'s2'}, {name:'s3',value:{colorValue:'gold'}}],
                [{name:'s3'}, {name:'s4',value:{colorValue:'gold'}}],
				[{name:'s4'}, {name:'s10',value:{colorValue:'gold'}}],
				[{name:'s10'}, {name:'s11',value:{colorValue:'gold'}}],
				[{name:'s5'}, {name:'s6',value:{colorValue:'gold'}}],
				[{name:'s6'}, {name:'s7',value:{colorValue:'gold'}}],
				[{name:'s7'}, {name:'s8',value:{colorValue:'gold'}}],
				[{name:'s8'}, {name:'s9',value:{colorValue:'gold'}}],
				[{name:'s9'}, {name:'s10',value:{colorValue:'gold'}}],
				[{name:'s10'}, {name:'s11',value:{colorValue:'gold'}}],
		]
		},
	  markPoint:{
			symbol:'emptyCircle',
			symbolSize:function(v){
				return v/5
			},
			effect:{
			    show:true,
                type:'scale',
                period:10,
                color:'gold',				
			},
			itemStyle:{
				normal:{
					label:{
						show:false,
					},
				},
				emphasis:{
					label:{
						show:false,
					},
				},
			},
			data:[
			   {name:'s1',value:50,
			       tooltip:{
					   formatter:'小乙<br/>时间:8:30am<br/>出发地:东兴小区'
				   },
			   },
			   {name:'s5',value:50,
			       tooltip:{
					   formatter:'小丙<br/>时间:8:10am<br/>出发地:冼村'
				   },
			   },
			   {name:'s10',value:50,
			       //tooltip:{
				   //   formatter:'目的地天河城<br/>经度:113.328755<br/>纬度:23.137588'  
				   //},
			   },
			   {name:'s11',value:100,
			       tooltip:{
					   formatter:'时间:10:00am<br/>目的地:天河城购物广场<br/>小乙与小丙成功会合<br/>开始一天的逛街之旅'
				   },
			   },
			],
		},
      geoCoord:{
                 's1':[113.319283,23.129146],
                 's2':[113.321817,23.129877],
                 's3':[113.32776,23.129612],
                 's4':[113.328069,23.136798],
                 's5':[113.336953,23.131398],
                 's6':[113.336163,23.132711],
                 's7':[113.331384,23.132976],
                 's8':[113.330916,23.132212],
                 's9':[113.330701,23.13681],
                 's10':[113.329749,23.137463],
                 's11':[113.328976,23.137949],
    }
},
	
    ]
};


var myChart = BMapExt.initECharts(container);
window.onresize = myChart.onresize;
BMapExt.setOption(option);
                }
                );
                })();

